home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 38
/
Amiga Format CD38 (1999-03-15)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-04].iso
/
-seriously_amiga-
/
misc
/
football
/
exec
/
writematch.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1999-02-03
|
4KB
|
139 lines
/* ***********************************************************************
WRITE MATCH PROGRAM FOR FOOTBALL REXX SUITE
---------------------------------------------
Copyright Mark Naughton 1997
Version Date History
--------------------------------------------------------------------------
1.0 080597 Created. Designed to be called from Gameplay to write
the score directly to the Schedule file, giving an
error if the match has been played, leaving Gameplay
to update the Learn file.
100597 Changed command for deleting the Game.Stored file. Had
to set 'sdcount' to 1 as lines were being missed in the
recreation as the first was being stored at 0 instead
of 1 which was where the loop started. Had to amend
the loop which wrote it back as it added one extra
line which wasn't required. Swapped parameters in the
'pos' statement when checking the matches as it was
always overwriting matches that had been played.
100697 Changed position that the away team is picked from the
argument to 1 from 2. Was giving invalid values.
Changed method again, a draw meant that the positions
picked up were one out as it went for the 1st occurrence.
**************************************************************************
Procedure
---------
1. Split argument into league-name and match.
2. Check schedule file exists. If file-indicator exists then erase it.
3. Split match into home and away teams and their scores.
4. Read Schedule file into an array.
5. Search array for the match supplied and if found, overwrite the scores.
6. If a match has been played and updated, then rewrite the Schedule file
back. Then write the file-indicator to tell Gameplay that a match has
been stored. Then exit.
************************************************************************** */
PARSE ARG league_file
version = 1
input_file = '.sf'
output_file = 'RAM:Game.stored'
separator = '*'
sdlines. = '???'
sdcount = 1
not_played = '__ __'
league_file = "Data/" || league_file
parse var league_file league " " match
if exists(league || input_file) = 0 then exit
if exists(output_file) > 0 then
address command 'delete >NIL: 'output_file
do i=1 to words(match)
if datatype(word(match,i)) = 'NUM' then do
goalsh = word(match,i)
goalsa = word(match,i+1)
placeh = find(match,goalsh) - 1
placea = find(match,goalsh) + 2
teamh = subword(match,1,placeh)
teama = subword(match,placea)
leave
end
end
if open(datafile3,league || input_file,'r') then do
do while ~eof(datafile3)
line = readln(datafile3)
line = strip(line)
sdlines.sdcount = line
sdcount = sdcount + 1
end
close(datafile3)
end
else do
say
say "ERROR : (WriteMatch)"
say
say "Cannot open '"league || input_file"' for reading."
exit
end
marker = 0
do i=1 to sdcount
if pos(sdlines.i,separator) = 0 then do
if find(sdlines.i,teamh) = 1 then do
if find(sdlines.i,teama) > 1 then do
if pos(not_played,sdlines.i) > 0 then do
sdlines.i = overlay(right(goalsh,2),sdlines.i,32)
sdlines.i = overlay(right(goalsa,2),sdlines.i,37)
marker = 1
leave
end
else
marker = 0
end
end
end
end
if marker = 1 then do
if open(datafile3,league || input_file,'w') then do
do i=1 to sdcount-1
if i < sdcount-1 then
writeln(datafile3,sdlines.i)
else
writech(datafile3,sdlines.i)
end
close(datafile3)
if open(datafile1,output_file,'w') then do
writeln(datafile1,"Game stored in '"league||input_file"'.")
close(datafile1)
end
else do
say
say "ERROR : (WriteMatch)"
say
say "Match has been stored but the indicator file could not be"
say "created."
exit
end
end
else do
say
say "ERROR : (WriteMatch)"
say
say "Cannot open '"league || input_file"' for writing."
end
end
exit
/* *********************************************************************** */